package com.szr.leex.po.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * week enum
 * Created by WangChen on 2018/9/9 11:35.
 */
public enum  WeekEnum {

    MONDAY("MONDAY", "星期一", "monday"),
    TUESDAY("TUESDAY", "星期二", "tuesday"),
    WEDNESDAY("WEDNESDAY", "星期三", "wednesday"),
    THURSDAY("THURSDAY", "星期四", "thursday"),
    FRIDAY("FRIDAY", "星期五", "friday"),
    SATURDAY("SATURDAY", "星期六", "saturday"),
    SUNDAY("SUNDAY", "星期天", "sunday");

    private String code;
    private String name;
    private String value;

    WeekEnum(String code, String name, String value){
        this.code = code;
        this.name = name;
        this.value = value;
    }

    private static final Map<String, WeekEnum> codeMap;

    static {
        codeMap = new HashMap<>();
        for (WeekEnum value : WeekEnum.values()) {
            codeMap.put(value.getCode(), value);
        }
    }

    public static WeekEnum getEnumInfo(String code) {
        return codeMap.get(code);
    }

    public static String getNameByKey(String code) {
        WeekEnum value = codeMap.get(code);
        if (value != null) {
            return value.getName();
        }
        return "";
    }

    public boolean equals(String code) {
        return this.getCode().equals(code);
    }

    @Override
    public String toString() {
        return this.getCode();
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getValue() {
        return value;
    }

    public void setValue(String value) {
        this.value = value;
    }
}
